package com.google.android.exoplayer2.source.ads;

import android.net.Uri;
import androidx.annotation.CheckResult;
import java.util.Arrays;
import o.amm;

public final class AdPlaybackState {
    public static final AdPlaybackState ˏ = new AdPlaybackState(new long[0]);
    public final long ˊ;
    public final b[] ˋ;
    public final int ˎ;
    public final long[] ॱ;
    public final long ॱॱ;

    public static final class b {
        public final int ˊ;
        public final long[] ˋ;
        public final int[] ˎ;
        public final Uri[] ˏ;

        public b() {
            this(-1, new int[0], new Uri[0], new long[0]);
        }

        private b(int i, int[] iArr, Uri[] uriArr, long[] jArr) {
            amm.ˊ(iArr.length == uriArr.length);
            this.ˊ = i;
            this.ˎ = iArr;
            this.ˏ = uriArr;
            this.ˋ = jArr;
        }

        public int ॱ() {
            return ˊ(-1);
        }

        public int ˊ(int i) {
            int i2 = i + 1;
            while (i2 < this.ˎ.length && this.ˎ[i2] != 0 && this.ˎ[i2] != 1) {
                i2++;
            }
            return i2;
        }

        public boolean ˎ() {
            return this.ˊ == -1 || ॱ() < this.ˊ;
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null || getClass() != obj.getClass()) {
                return false;
            }
            b bVar = (b) obj;
            if (this.ˊ == bVar.ˊ && Arrays.equals(this.ˏ, bVar.ˏ) && Arrays.equals(this.ˎ, bVar.ˎ) && Arrays.equals(this.ˋ, bVar.ˋ)) {
                return true;
            }
            return false;
        }

        public int hashCode() {
            return (((((this.ˊ * 31) + Arrays.hashCode(this.ˏ)) * 31) + Arrays.hashCode(this.ˎ)) * 31) + Arrays.hashCode(this.ˋ);
        }

        @CheckResult
        public b ˊ(long[] jArr) {
            boolean z = this.ˊ == -1 || jArr.length <= this.ˏ.length;
            amm.ˊ(z);
            if (jArr.length < this.ˏ.length) {
                jArr = ॱ(jArr, this.ˏ.length);
            }
            return new b(this.ˊ, this.ˎ, this.ˏ, jArr);
        }

        @CheckResult
        private static long[] ॱ(long[] jArr, int i) {
            int length = jArr.length;
            int max = Math.max(i, length);
            long[] copyOf = Arrays.copyOf(jArr, max);
            Arrays.fill(copyOf, length, max, -9223372036854775807L);
            return copyOf;
        }
    }

    public AdPlaybackState(long... jArr) {
        int length = jArr.length;
        this.ˎ = length;
        this.ॱ = Arrays.copyOf(jArr, length);
        this.ˋ = new b[length];
        for (int i = 0; i < length; i++) {
            this.ˋ[i] = new b();
        }
        this.ˊ = 0;
        this.ॱॱ = -9223372036854775807L;
    }

    private AdPlaybackState(long[] jArr, b[] bVarArr, long j, long j2) {
        this.ˎ = bVarArr.length;
        this.ॱ = jArr;
        this.ˋ = bVarArr;
        this.ˊ = j;
        this.ॱॱ = j2;
    }

    public int ˊ(long j) {
        int length = this.ॱ.length - 1;
        while (length >= 0 && ˎ(j, length)) {
            length--;
        }
        return (length < 0 || !this.ˋ[length].ˎ()) ? -1 : length;
    }

    public int ˏ(long j) {
        int i = 0;
        while (i < this.ॱ.length && this.ॱ[i] != Long.MIN_VALUE && (j >= this.ॱ[i] || !this.ˋ[i].ˎ())) {
            i++;
        }
        return i < this.ॱ.length ? i : -1;
    }

    @CheckResult
    public AdPlaybackState ˊ(long[][] jArr) {
        b[] bVarArr = (b[]) Arrays.copyOf(this.ˋ, this.ˋ.length);
        for (int i = 0; i < this.ˎ; i++) {
            bVarArr[i] = bVarArr[i].ˊ(jArr[i]);
        }
        return new AdPlaybackState(this.ॱ, bVarArr, this.ˊ, this.ॱॱ);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        AdPlaybackState adPlaybackState = (AdPlaybackState) obj;
        if (this.ˎ == adPlaybackState.ˎ && this.ˊ == adPlaybackState.ˊ && this.ॱॱ == adPlaybackState.ॱॱ && Arrays.equals(this.ॱ, adPlaybackState.ॱ) && Arrays.equals(this.ˋ, adPlaybackState.ˋ)) {
            return true;
        }
        return false;
    }

    public int hashCode() {
        return (((((((this.ˎ * 31) + ((int) this.ˊ)) * 31) + ((int) this.ॱॱ)) * 31) + Arrays.hashCode(this.ॱ)) * 31) + Arrays.hashCode(this.ˋ);
    }

    private boolean ˎ(long j, int i) {
        boolean z = true;
        long j2 = this.ॱ[i];
        if (j2 != Long.MIN_VALUE) {
            if (j >= j2) {
                z = false;
            }
            return z;
        } else if (this.ॱॱ == -9223372036854775807L || j < this.ॱॱ) {
            return true;
        } else {
            return false;
        }
    }
}
